# -*- encoding: utf-8 -*-
"""
@author: CarpeDiem
@data: 22/9/22
@version: 0.1
@description: 
@method: 比较
"""

def mergeSimilarItems(items1, items2):
    items = items1 + items2
    items_dict = {}
    for key, value in items:
        items_dict[key] = items_dict.get(key, 0) + value
    result_list = sorted(items_dict.items(), key=lambda item : item[0])
    result_list = [list(element) for element in result_list]
    return result_list

def main():
    items1 = [[1,1],[3,2],[2,3]]
    items2 = [[2,1],[3,2],[1,3]]
    print(mergeSimilarItems(items1, items2))


main()